package com.chinawlx.wlxteacher.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chinawlx.wlxteacher.R;
import com.chinawlx.wlxteacher.utils.WLXDateUtil;
import com.chinawlx.wlxteacher.wlx_schedule_score;

import java.util.List;

/**
 * 教学意见适配器
 * Created by wlx on 16/10/14.
 */

public class WLXTeachIdeaAdapter extends RecyclerView.Adapter<WLXTeachIdeaAdapter.TeachIdeaHolder>{
    private Context mContext;
    private List<wlx_schedule_score> wlxScheduleScores;
    public WLXTeachIdeaAdapter(Context mContext,List<wlx_schedule_score> wlxScheduleScores){
        this.mContext=mContext;
        this.wlxScheduleScores=wlxScheduleScores;
    }
    @Override
    public TeachIdeaHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //该方法的item设置为match_parent时无效
//        View view = View.inflate(mContext, R.layout.item_teachidea, null);
        //新方法,使match_parent生效
        LayoutInflater mInflater = LayoutInflater.from(mContext);
        View view = mInflater.from(mContext).inflate(R.layout.item_teachidea, parent, false);
        TeachIdeaHolder holder = new TeachIdeaHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(TeachIdeaHolder holder, int position) {
        holder.content.setText(wlxScheduleScores.get(position).getContent());
        String data = WLXDateUtil.getDataToDay(wlxScheduleScores.get(position)
                .getCreation_date());
        holder.data.setText(data);
    }


    @Override
    public int getItemCount() {
        return wlxScheduleScores==null?0:wlxScheduleScores.size();
    }

    class TeachIdeaHolder extends RecyclerView.ViewHolder{
        TextView content;
        TextView data;
        public TeachIdeaHolder(View itemView) {
            super(itemView);
            content = (TextView) itemView.findViewById(R.id.tv_content_teach);
            data = (TextView) itemView.findViewById(R.id.tv_data_teach);
        }
    }
}
